var RunLayer = cc.Layer.extend({
	arr:null,
	scene:null,
	clock:null,
	ctor:function (parent) {
		this._super(parent);
		parent.addChild(this, 10);
		this.init();
	},
	init:function () {
		ll.run = this;
		
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callKill = cc.callFunc(function(p){
			var seq = cc.sequence(cc.fadeOut(0.5),cc.callFunc(function(){
				p.removeFromParent(true);	
			}, this));
			p.runAction(seq);
		}, this); 

		this.callNext.retain();
		this.callKill.retain();
		//时钟
		this.clock = new Clock(this);
		//药品库
		this.lib = new Lib(this);
		this.lib.init([TAG_LIB_AMPULLA,TAG_LIB_BEAKER,TAG_LIB_CONICAL,TAG_LIB_CYLINDER,TAG_LIB_TESTTUBE,TAG_LIB_VOLUMETRIC]);

		this.ampulla = new Ampulla(this);
	},
	loadInLib:function(obj, pos, tarPos,next,delay){
		obj.setPosition(pos);
		if(next == null){
			next = true;
		}
		if(delay == null){
			delay = 1;
		}		
		var ber = $.bezier(pos, tarPos, delay);
		if(next){
			var seq = cc.sequence(ber, this.callNext);
		}else{
			var seq = cc.sequence(ber);
		}	
		obj.runAction(seq);
	},

	kill:function(obj){
		var fade = cc.fadeTo(0.5,0);
		var func = cc.callfunc(function(){
			obj.removeFromParent(true);
		},this);
		var seq = cc.sequence(fade,func);
		obj.runAction(seq)
	},
	flowNext:function(){
		gg.flow.next();
	},
	onExit:function(){
		this._super();
		this.callNext.release();
		this.callKill.release();
	}
});